<?php
class Default_Forms_UploadImageForm extends Zend_Form {
	function init() {
		$this->setAction('')
				->setMethod('POST')
				->setAttrib('class','form-horizontal');
				
		$image = new Zend_Form_Element_File('file_image');
		$image->setLabel('Chọn file ảnh(Không quá 3M)')
				->setDestination(PUBLIC_PATH . '/images')
				->addValidator('Size', false, '3MB')
				->setIgnore(true);
				
		$image_value = new Zend_Form_Element_Hidden("images");
		
		$title = $this->createElement('text', 'title');
		$title->setRequired ( true )
		            ->addFilter('StringTrim')
		            ->setAttrib('class','form-control')
		            ->setLabel('Tiêu đề ảnh');
		            
		$is_me = $this->createElement('checkbox','stick',array ('label'	=> 'Ảnh này do tôi tự làm'));
		
		$source = $this->createElement('text', 'source');
		
		$source->setRequired ( true )
		            ->addFilter('StringTrim')
		            ->setAttrib('class','form-control')
		            ->setLabel('Nguồn của ảnh');
		            
		$submit = $this->createElement('submit','submit',array ('label' => 'Đăng ảnh' ,'class'	=>'btn btn-default'));
		
		$cancel = $this->createElement('submit','cancel',array ('label' => 'Bỏ qua' ,'class'	=>'btn btn-default'));
		
		$this->addElement($image)
				->addElement($image_value)
				->addElement($title)
				->addElement($is_me)
				->addElement($source)
				->addElement($submit)
				->addElement($cancel);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
										'ViewHelper',
										'Errors',
										'Description',
										array(	
											array('data'	=> 'HtmlTag'),
											array('tag'		=> 'div','class'	=> 'col-md-6')),
										array('label',
											array('class'	=> 'col-md-3 control-label')),
										array(
											array('row'	=> 'HtmlTag',),
											array('class'=>'form-group')
		        						)
									)
								);
		$image_value->setDecorators(array('ViewHelper'));
		$submit->setDecorators(array(
								'ViewHelper',
						       ));
		$cancel->setDecorators(array(
								'ViewHelper',
									)
						       );
       $image->setDecorators(array(
			'File',
			'Description',
			'Errors',
			array(array('data'=>'HtmlTag'), array('tag' => 'div',"class"	=> "controls")),
			array('label',array('class'	=> 'control-label','requiredSuffix'=>'(*)')),
			array(
				array('row'	=> 'HtmlTag',),
				array('class'=>'control-group ','tag'	=> 'div')
			),
		));
		$is_me->setDecorators(array(
								'ViewHelper',
								array(
									array('data'	=> 'HtmlTag'),
									array('tag'		=>	'span','for'=>'remember',"openOnly"	=> true,'class'	=> "col-md-9 col-md-offset-3")
								),
								array('label',
											array("placement"	=> Zend_Form_Decorator_PrepareElements::APPEND),"closeOnly"	=> true,'escape' => false),
								array(
									array('row'	=> 'HtmlTag'),
									array('tag'	=> 'div','class'	=> "form-group"))
									));
	}
}